<%@ include file="../../../include.jsp" %>

<tiles:insertDefinition name="component.layout.SubPanel">
   <tiles:putAttribute name="title" value="Login" />
   <tiles:putAttribute name="content">
      <script>
      function status_fb() {
         FB.getLoginStatus(function(response) {
           if (response.status === 'connected') {
        	     var accessToken = response.authResponse.accessToken;
              window.location = "<c:url value='/j_spring_facebook_security_check' />?token="
            		  + accessToken;
           } else if (response.status === 'not_authorized') {
             // the user is logged in to Facebook, 
             // but has not authenticated your app
           } else {
             // the user isn't logged in to Facebook.
           }
          });
      }
      
      function login_fb() {
    	  FB.login(function(response) {
    		   if (response.authResponse) {
    		     console.log('Welcome!  Fetching your information.... ');
    		     FB.api('/me', function(response) {
    		       console.log('Good to see you, ' + response.name + '.');
    		     });
    		   } else {
    		     console.log('User cancelled login or did not fully authorize.');
    		   }
    		 }, {scope: 'email,user_birthday'});
      }
      </script>
      
      <a href="javascript:status_fb()">Status</a>
      
      <a href="javascript:login_fb()">Login</a>
      
   </tiles:putAttribute>
</tiles:insertDefinition>
